package com.jyw.business.obstacles.domain.dto.web;

import com.jyw.business.obstacles.domain.ObsOrderFault;
import com.jyw.business.obstacles.domain.ObsOrderSend;
import com.jyw.common.utils.DateUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * 转单请求实体
 */
@Data
@ApiModel("转单请求实体")
public class OrderRedirectDto extends BaseOrderDto implements Serializable {

    @ApiModelProperty(value = "派单对象类型", required = true)
    @NotNull(message = "派单对象类型不能为空")
    private Integer sendObjType;

    @ApiModelProperty(value = "派单对象标识", required = true)
    @NotNull(message = "派单对象标识为空")
    private Long sendObjId;

    @ApiModelProperty("派单所属小组")
    private Long sendTeam;

    @ApiModelProperty("转单原因")
    private String reason;

    @ApiModelProperty("转单说明")
    private String remark;

    public ObsOrderSend buildSend(ObsOrderFault orderFault) {
        ObsOrderSend send = new ObsOrderSend();
        send.setOrderNum(orderFault.getOrderNum());
        send.setSendType(getSendObjType());
        switch (send.getSendType()) {
            case 1:
                send.setSendUser(getSendObjId());
                send.setSendTeam(getSendTeam());
                break;
            case 2:
                send.setSendTeam(getSendObjId());
                break;
            case 3:
                send.setSendDept(getSendObjId());
                break;
        }
        send.setCreateTime(DateUtils.getNowDate());
        send.setType(2);
        return send;
    }

}
